package com.yao.longhan.presenter.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.yao.longhan.constant.Constant;
import com.yao.longhan.ui.fragment.BookcaseItemFragment;

/**
 * Created by heyao on 2017/7/31.
 */

public class BookcaseAdapter extends FragmentPagerAdapter {

    private String[] titles;

    public BookcaseAdapter(FragmentManager fm, String[] title) {
        super(fm);
        this.titles = title;
    }

    @Override
    public Fragment getItem(int position) {
        Bundle bundle = new Bundle();
        bundle.putInt(Constant.CHANNEL, position);
        return BookcaseItemFragment.instance(bundle);
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
